<template>
  <div>
    <view-doc v-if="isDoc" :url="url" />
    <view-pdf v-if="isPdf" :url="url" />
    <view-excel v-if="isExcel" :url="url" />
  </div>
</template>

<script>
//引入VueOfficeDocx组件
import viewDoc from "@/components/viewDoc";
import viewExcel from "@/components/viewExcel";
import viewPdf from "@/components/viewPdf";

export default {
  components: {
    viewDoc,
    viewExcel,
    viewPdf,
  },
  data() {
    return {
      url: "",
    };
  },
  methods: {},
  created(){
    // console.log("this==",this.$route);
    this.url = this.$route.query.url;
  },
  computed: {
    isDoc() {
      if (
        this.url &&
        (this.url.indexOf("doc") !== -1 || this.url.indexOf("docx") !== -1)
      ) {
        return true;
      }
      return false;
    },
    isPdf() {
      if (this.url && this.url.indexOf("pdf") !== -1) {
        return true;
      }
      return false;
    },
    isExcel() {
      if (
        this.url &&
        (this.url.indexOf("xls") !== -1 || this.url.indexOf("xlsx") !== -1)
      ) {
        return true;
      }
      return false;
    },
  },
};
</script>
